<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.7"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Parola for Arduino: Parola Library</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="MajicDesigns_Logo.png"/></td>
  <td id="projectalign">
   <div id="projectname">Parola for Arduino<span id="projectnumber">&#160;3.7</span>
   </div>
   <div id="projectbrief">Text effects for LED Matrix modular hardware</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.7 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('page_software.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">Parola Library</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h2>The Library </h2>
<p>The Parola library is implemented using the MD_MAX72xx library for hardware control. The library implements functions to simplify the implementation of text special effects on the LED matrix.</p><ul>
<li>Text left, right or center justification in the display</li>
<li>Text scrolling, appearance and disappearance effects</li>
<li>Control display parameters and animation speed</li>
<li>Support for hardware SPI interface</li>
<li>Multiple virtual displays (zones) in each string of LED modules</li>
<li>User defined fonts and/or individual characters substitutions</li>
</ul>
<h3>External Dependencies</h3>
<ul>
<li>Parola uses the MD_MAX72xx library for hardware level control primitives. The latest copy of this library can be found <a href="http://github.com/MajicDesigns/MAX72xx">here</a>.</li>
</ul>
<hr  />
<h2>Display Zones </h2>
<p>A matrix display can be treated as a single contiguous set of modules or it can be split into multiple 'virtual' displays (zones). Prior to version 2.0 of the library, each display was effectively a single zone.</p>
<p>A zone is a contiguous subset of one or more display modules (LED matrices) that has all the attributes of a display - animation, speed, font, spacing, etc. This allows complex displays to be created. For example, one part can show relatively static text while a different one has animation and movement.</p>
<p>For backward compatibility, all the methods from version 1 remain. If the new library is compiled with older user source code, the library defaults to using a single zone for the whole display. Zone-aware functions have an added parameter to specify the zone to which the method invocation applies. Methods invoked without specifying a zone (such as set*()) usually have their effect applied to all zones.</p>
<h3>More Information</h3>
<ul>
<li><a href="https://arduinoplusplus.wordpress.com/2017/04/18/parola-a-to-z-multi-zone-displays/">Parola A to Z - Multi Zone Displays</a></li>
<li><a href="https://arduinoplusplus.wordpress.com/2017/03/15/parola-a-to-z-double-height-displays/">Parola A to Z - Double Height Displays</a></li>
</ul>
<hr  />
<h2>Fonts </h2>
<p>The standard MD_MAX72xx library font can be substituted with a user font definition conforming to the font encoding rules in the MD_MAX72XX documentation. New fonts can be designed with the the MD_MAX72xx font builder.</p>
<p>Each zone can have its own substituted font. The default font can be reselected for the zone by specifying a nullptr font table pointer.</p>
<h3>More Information</h3>
<ul>
<li><a href="https://arduinoplusplus.wordpress.com/2016/11/08/parola-fonts-a-to-z-defining-fonts/">Parola A to Z - Defining Fonts</a></li>
<li><a href="https://arduinoplusplus.wordpress.com/2016/11/13/parola-fonts-a-to-z-managing-fonts/">Parola A to Z - Managing Fonts</a></li>
<li><a href="https://arduinoplusplus.wordpress.com/2018/09/23/parola-a-to-z-optimizing-flash-memory/">Parola A to Z - Optimizing Flash Memory</a></li>
</ul>
<hr  />
<h2>User Characters </h2>
<p>Individual characters can be substituted for user character definitions. These can be added and deleted to individual zones as required.</p>
<p>The character data is the same format as a single character from the font definition file, and is held in a local lookup table that is parsed before loading the defined font character. If a character is specified with a code the same as an existing character, the existing data will be substituted for the new data.</p>
<p>ASCII 0 character ('\0') cannot be substituted as this denotes the end of string character for C++ and cannot be used in an actual string.</p>
<p>The library only retains a pointer to the user data definition, so the data must remain in scope. Also, any changes to the data storage in the calling program will be reflected by the library the next time the character is used.</p>
<h3>More Information</h3>
<ul>
<li><a href="https://arduinoplusplus.wordpress.com/2016/11/08/parola-fonts-a-to-z-defining-fonts/">Parola A to Z - Defining Fonts</a></li>
<li><a href="https://arduinoplusplus.wordpress.com/2016/11/13/parola-fonts-a-to-z-managing-fonts/">Parola A to Z - Managing Fonts</a></li>
<li><a href="https://arduinoplusplus.wordpress.com/2020/03/21/parola-a-to-z-handling-non-ascii-characters-utf-8/">PArola A to Z - Handling non-ASCII (UTF-8) Characters</a></li>
</ul>
<hr  />
<h2>Sprite Text Effect </h2>
<p>The PA_SPRITE text effect requires additional information, as it extends the functionality of the library to include fully customizable, user defined, animated bitmaps to wipe text on and off the LED matrix display.</p>
<p>Each frame is defined by a sequence of numbers that encode the columns of the bitmap. The least significant bit is at the top of the bitmap. If the sprite has a front and rear, the bitmap should be defined for the sprite moving to the right. The library will mirror reverse the image when it moves left. The sprites are essentially defined in the same way as the character font and the same tools can be used to define the data for the sprite bitmap.</p>
<p>A sprite has at least one frame. If more than one frame is required, a similar definition is created for each frame of the animation, and a data table constructed defining the animated sprite. To ensure smooth animations, remember that once the last frame is reached, it will loop back to the first, so avoid discontinuities between the two ends of the data table.</p>
<p>The library is given the sprite definition setSpriteData() method and the text effect is specified using the effect id PA_SPRITE.</p>
<h3>More Information</h3>
<ul>
<li><a href="https://arduinoplusplus.wordpress.com/2018/04/19/parola-a-to-z-sprite-text-effects/">Parola A to Z - Sprite Text Effects</a></li>
</ul>
<hr  />
<h2>Conditional Compilation Switches </h2>
<p>The library allows the run time code to be tailored through the use of compilation switches. The compile options start with ENA_ and are documented in the section related to the main header file <a class="el" href="_m_d___parola_8h.html" title="Main header file for the MD_Parola library.">MD_Parola.h</a>.</p>
<p><em>NOTE</em>: Compile switches must be edited in the library header file. Arduino header file 'mashing' during compilation makes the setting of these switches from user code completely unreliable.</p>
<h3>More Information</h3>
<ul>
<li><a href="https://arduinoplusplus.wordpress.com/2018/09/23/parola-a-to-z-optimizing-flash-memory/">Parola A to Z - Optimizing Flash Memory</a></li>
</ul>
<hr  />
<h2>Implementing New Text Effects </h2>
<p>Each of the selected text effects is implemented as a function. This makes it easy to add new effects:</p><ul>
<li>Choose a name for the effect and add it to the textEffect_t enumerated type.</li>
<li>Clone an existing method and modify it according to the guidelines below.</li>
<li>Add the function prototype for the new effect to the <a class="el" href="class_m_d___p_zone.html">MD_PZone</a> class definition in the <a class="el" href="_m_d___parola_8h.html" title="Main header file for the MD_Parola library.">MD_Parola.h</a> file.</li>
<li>Modify the zoneAnimate() method in <a class="el" href="_m_d___p_zone_8cpp.html" title="Implements MD_PZone class methods.">MD_PZone.cpp</a> to invoke the new method.</li>
</ul>
<h3>New Text Effects</h3>
<p>The effects functions are implemented as finite state machines that are called with the frequency set by the setSpeed() method. The class variable _fsmState holds the state from the last invocation of an effect method.</p>
<p>An effect method can work in one of 2 ways:</p><ul>
<li><em>Additive</em>: where the animation frames are incrementally built up to the initial display. With this method, the function will need to use the getFirstChar() and getNextChar() methods to build up the displayed text, column by column.</li>
<li><em>Subtractive</em>: where the final displayed text is placed in the buffer using the commonPrint() method and the elements that are not visible at that stage of the animation are removed.</li>
</ul>
<p>Which algorithm is used depends on the type animation and what is convenient for the coder. Examples of both are found in the supplied library text effects.</p>
<p>Each effect method is implemented in 2 parts. One part implements the text move IN to the display (method parameter bIn is true) and the other when the text is moving OUT of the display (bIn false). Because the IN and OUT effects can be different for a display cycle, the method must not assume that the first part was ever called. The first phase should always end with the text in its display position (depending on the alignment specified) and the second phase should assume the text is in that position when called. Text position parameters are held in the class variables _limitLeft and _limitRight found in the library header file.</p>
<p>The first phase starts with _fsmState set to INITIALISE and ends when the state is set to PAUSE within the effect method. The second phase starts with a PAUSE state and ends when the state is set to END by the method. Aside from the INITIALISE state (set by the displayReset() method), all other state changes are under the control of the effect functions. Delays between frames and the pause between IN and OUT are handled outside of the effect method.</p>
<h3>More Information</h3>
<ul>
<li><a href="https://arduinoplusplus.wordpress.com/2017/02/10/parola-a-to-z-text-animation/">Parola A to Z - Text Animation</a></li>
<li><a href="https://arduinoplusplus.wordpress.com/2017/03/02/parola-a-to-z-managing-animation/">Parola A to Z - Managing Animation</a></li>
</ul>
<hr  />
<h2>Coding Tips </h2>
<ul>
<li>The MD_MAX72XX library sets the origin for the LED matrix at the top right of the display. This makes the leftmost text column a higher column number that the far right column. Sometimes this is not intuitive when coding and is worth remembering. Rows are numbered from top to bottom, 0-7.</li>
<li>Ensure that a new effect is tested in combination with other effects to make sure that transitions are smooth and the IN and OUT effects combine well. Common errors are misaligned entry compared to exit, with causes a small jump in the text position when the effects are combined.</li>
<li>Display update times grow proportionally with the number of modules in a display, so some timing parameters may need to adapt. Hardware SPI runs approximately 10 times faster and the delay increase is not appreciable with up to 12 modules. For the arbitrary pin outs, using shiftout(), a 6 module chain updates in approximately 14ms on an Uno, while a 12 module display takes around 25ms. Most of the time taken is to physically update the display, as animating frames takes about 1-2ms to update in the MD_MAX72XX display buffers. </li>
</ul>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="index.html">Main Page</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.7 </li>
  </ul>
</div>
</body>
</html>
